from datetime import datetime
from django.contrib.sitemaps import Sitemap
from django.core.urlresolvers import reverse
from pyplog.blog.models import Post
from pyplog.pages.models import Page
from pyplog.photos.models import Photo

class BlogMap(Sitemap):
	changefreq = "never"
	priority = 0.5
	
	def items(self):
		return Post.public_objects.all()
	
	def lastmod(self, obj):
		return obj.published
	
class BlogIndexMap(Sitemap):
	changefreq = "daily"
	priority = 0.9
	
	def items(self):
		return [None]
	
	def location(self, obj):
		return reverse("blog-index")
	
	def lastmod(self, obj):
		return Post.public_objects.all()[0].published

class PhotoMap(Sitemap):
	changefreq = "never"
	priority = 0.2
	
	def items(self):
		return Photo.public_objects.all()
	def lastmod(self, obj):
		return obj.published
	
class PageMap(Sitemap):
	changefreq = "never"
	priority = 0.8
	
	def items(self):
		return Page.objects.all()
